﻿using System;

namespace Mojo.Widgets
{
    /// <summary>
    /// &lt;div x-mojo-element="WebView" id="WebId" class="WebClass" name="WebName"&gt;lt;div&gt;
    /// </summary>
    public class WebView
    {
        /// <summary>
        /// Retrieves the current history state from the Browser server. Will call successCb with results.
        /// </summary>
        /// <param name="success"></param>
        public void GetHistoryState(Delegate success)
        {
        }

        /// <summary>
        /// Saves the current view to the specified file. The save region is optional. If omitted then the full view will be saved to fname.
        /// </summary>
        /// <param name="fname"></param>        
        public void SaveViewToFile(string fname)
        {
        }

        /// <summary>
        /// Saves the current view to the specified file. The save region is optional. If omitted then the full view will be saved to fname.
        /// </summary>
        /// <param name="fname"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public void SaveViewToFile(string fname, int left, int top, int width, int height)
        {
        }

        /// <summary>
        /// Enhances the showing of a clicked link. This setting is on a per-WebView widget basis.
        /// </summary>
        /// <param name="show"></param>
        public void SetShowClickedLink(bool show)
        {
        }	 

        public void Copy(Delegate callback)
        {
        }


        public void SelectAll()
        {
        }

        /// <summary>
        /// WebView gets out of the spotlight mode, in which gestures only go into the spotlight rect. Gestures modified by meta go into the adapter and not into the spotlight.
        /// </summary>
        public void PluginSpotlightRemove()
        {
        }

        /// <summary>
        /// Creates spotlight at given rectangle.
        /// </summary>
        public void PluginSpotlightCreate(int left, int top, int right, int bottom, string mode, bool notifyClient)
        {
        }

        /// <summary>
        /// Resizes the input file (PNG format only) to the specified width/height and writes the new image to the specified output file. Note that pathnames must be relative names (e.g., '/tmp/image.png') rather than URL-like (e.g., 'file://var/usr/applications/myApp/images/image.png').
        /// </summary>
        /// <param name="inFileName"></param>
        /// <param name="outFileName"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public void ResizeImage(string inFileName, string outFileName, int width, int height)
        {
        }

        /// <summary>
        /// Reloads the currently loaded page.
        /// </summary>
        public void ReloadPage()
        {
        }

        /// <summary>
        /// If in an editable field, inserts a string at the current cursor position.
        /// </summary>
        /// <param name="str"></param>
        public void InsertStringAtCursor(string str)
        {
        }

        /// <summary>
        /// Enables or disables popup blocking. This setting is on a per-WebView widget basis.
        /// </summary>
        /// <param name="block"></param>
        public void SetBlockPopups(bool block)
        {
        }

        /// <summary>
        /// Enables or disables accepting cookies. This setting is on a per-WebView widget basis.
        /// </summary>
        /// <param name="accept"></param>
        public void SetAcceptCookies(bool accept)
        {
        }

        /// <summary>
        /// Sets the top margin (in pixels).
        /// </summary>
        /// <param name="top"></param>
        public void SetTopMargin(int top)
        {
        }

        public void ClearCache()
        {
        }

        public void ClearCookies()
        {
        }

        /// <summary>
        /// Generates a 64x64 pixel icon from a portion of an input file. The output icon will be given a drop shadow and sheen consistent with other launcher icons.
        /// </summary>
        public void GenerateIconFromFile(string src, string dst, int left, int top, int right, int bottom)
        {
        }

        /// <summary>
        /// Deletes an image from the file system.
        /// </summary>
        /// <param name="image"></param>
        public void DeleteImage(string image)
        {
        }

        public void Focus()
        {
        }

        public void Blur()
        {
        }

        public void GoBack()
        {
        }

        public void GoForward()
        {
        }

        public void OpenURL(string url)
        {

        }

        public void StopLoad()
        {
        }

        /// <summary>
        /// Clears session history. This setting is on a per-WebView widget basis.
        /// </summary>
        public void ClearHistory()
        {
        }

        /// <summary>
        /// Function {callback}	 Determines if an editable field is in focus. Will call "callback" with boolean value.
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public bool IsEditing(Action<bool> callback)
        {
            return false;
        }

        /// <summary>
        /// Enables or disables JavaScript. This setting is on a per-WebView widget basis.
        /// </summary>
        /// <param name="enable"></param>
        public void SetEnableJavaScript(bool enable)
        {
        }

        /// <summary>
        /// Adds a URL redirect. When the browser server nagivates to a URL matching urlRe and redirect is true, then it will not navigate to that URL and will instead send a Mojo.Event.webViewUrlRedirect event.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="redirect"></param>
        /// <param name="userData"></param>
        /// <param name="type"></param>
        public void AddUrlRedirect(string url, bool redirect, object userData, int type)
        {
        }

        /// <summary>
        /// Adds all entries from the system's command/resource handlers table. The optional appId parameter can be used to omit all command/resource handler entries that match a given app ID.
        /// </summary>
        /// <param name="appId"></param>
        public void AddSystemRedirects(string appId)
        {
        }
    }

    public class WebViewAttributes : WidgetsCreateAttributes
    {
        /// <summary>
        /// Required. The initial URL to display.
        /// </summary>
        public string Url;

        /// <summary>
        /// Optional. The BrowserServer page identifier. This is used when the BrowserServer instructs an application to open a new page.
        /// </summary>
        public string PageIdentifier;

        /// <summary>
        /// Optional. The minimum font size that the browser will display.
        /// </summary>
        public int MinFontSize;

        /// <summary>
        /// Optional. The margin above the WebView that is scrolled off the screen when a new page is loaded.
        /// </summary>
        public int TopMargin;

        /// <summary>
        /// Optional. If true, cache this adapter; if false, do not. If undefined, use the browser-adapter default. Default is undefined.
        /// </summary>
        public bool CacheAdapter;

        /// <summary>
        /// Optional. If the host application wants to be called for every hyperlink click via Mojo.Event.webViewLinkClicked event.
        /// </summary>
        public bool InterrogateClicks;

        /// <summary>
        /// Optional. Styles a clicked link with grey background and border.
        /// </summary>
        public bool ShowClickedLink;
    }

    public class WebViewModel : WidgetsCreateModel
    {
    }
}
